﻿<Window x:Class="DynamicResourceDemo" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="DynamicResource Demo" Height="284" Width="308">
    <Window.Resources>
        <SolidColorBrush Color="Red" x:Key="testBrushResource" />
    </Window.Resources>
    <Grid>

        <Border Margin="7" BorderBrush="Gray" BorderThickness="1" VerticalAlignment="Top" Padding="7">
            <Grid>
                <TextBlock FontSize="18" Foreground="{DynamicResource ResourceKey=brushTitle}" Text="Form Title" VerticalAlignment="Top" />
                <TextBlock Foreground="{DynamicResource brushText}" VerticalAlignment="Top" Margin="11,32,11,0" Text="This is some form text." />
                <Button HorizontalAlignment="Right" Margin="0,50,11,11" Name="btnChange" Width="75" Height="25" VerticalAlignment="Top">Change</Button>
            </Grid>
        </Border>

        <Border Margin="7" BorderBrush="Gray" BorderThickness="1" VerticalAlignment="Bottom" Padding="7">
            <Grid Height="94">
                <TextBlock FontSize="18" Foreground="{DynamicResource ResourceKey=testBrushResource}" Text="StaticResource Looup" VerticalAlignment="Top" />
                <TextBlock Foreground="{DynamicResource testBrushResource}" VerticalAlignment="Top" Margin="11,32,11,0" Text="DynamicResource lookup." />
                <Button HorizontalAlignment="Right" Margin="0,0,12,11" Name="btnChangeBottom" Width="75" Height="25" VerticalAlignment="Bottom">Change</Button>
                <Button Height="25" Margin="89,0,92,11.44" Name="btnSwapBottom" VerticalAlignment="Bottom">Swap</Button>
            </Grid>
        </Border>

    </Grid>
</Window>
